#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python solely by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


Program 1.3.4 - Your first nested loops

Syntax:
python divisorpattern.py 10


Notes:
sys is a required import here in order to use command line arguments.
https://docs.python.org/2/tutorial/stdlib.html

int(sys.argv[x]) == Integer.parseInt(args[x])

The stop value in Python's range function is non-inclusive, thus the +1 below.
https://docs.python.org/2/library/functions.html#range

'''

import sys


def main():
    ''' Compute the powers of two to a user-defined exponent '''

    num_rows = int(sys.argv[1])
    for i in range(1, num_rows+1):   # range 'stop' value is non-inclusive
        for j in range(1, num_rows+1):
            if (j % i == 0) or (i % j == 0):
                print "*",   # trailing comma prevents newline, adds a space
            else:
                print " ",
        print i


if __name__ == '__main__':
    main()
